<template>
  <div class="iBox">
    <div class="top">
      <slot name="title"></slot>
      <p>查看全部></p>
    </div>
    <div class="itemsBox">
      <div class="items" v-for="items in itemArr" :key="items.id">
        <img :src="items.spu.picture" alt="" />
        <p>{{ items.spu.name }}</p>
        <p>{{ items.spu.desc }}</p>
        <p>￥{{ items.spu.price }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "MyItem",
  props: ["arr"],
  data() {
    return {
      itemArr: [],
    };
  },
  watch: {
    deep: true,
    arr(a) {
      this.itemArr = a.slice(0, 4);
    },
  },
  created() {
  },
};
</script>

<style lang="scss" scoped>
.iBox {
  width: 100%;
  background: #fff;
  margin-top: 20px;
  .top {
    width: 95%;
    margin: 0 auto;
    height: 60px;
    line-height: 60px;
    border-bottom: 1px solid #666;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    h5 {
      font-size: 20px;
      font-weight: 300;
    }
  }
  .itemsBox {
    width: 100%;
    display: flex;
    justify-content: space-between;
    .items {
      width: 200px;
      margin: 10px;
      text-align: center;
      padding: 10px;
      &:hover {
        transform: translateY(-6px) scale(1);
        transition: .5s;
        box-shadow: rgb(196, 194, 194) 0px 2px 5px;
      }
      img {
        width: 160px;
        height: 160px;
      }
      p {
        margin: 5px 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      :nth-child(3) {
        color: #666;
        font-size: 14px;
      }
      :nth-child(4) {
        color: red;
        font-size: 18px;
      }
    }
  }
}
</style>